package com.clickpaas.workinghours.service.Impl;

import com.bizcloud.ipaas.tbba4bf83484b4ed2aacba581fbfeac4d.  d20210220155135.model.TimeSheetDTO;
import com.bizcloud.ipaas.tbba4bf83484b4ed2aacba581fbfeac4d.  d20210220155135.model.TimeSheetDTOResponse;
import com.clickpaas.workinghours.dao.TimeSheetDao;
import com.clickpaas.workinghours.entity.TimeSheetEntity;
import com.clickpaas.workinghours.service.TimeSheetService;
import com.clickpaas.workinghours.utils.DataInfoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class TimeSheetServiceImpl implements TimeSheetService {
    @Resource
    private TimeSheetDao timeSheetDao;

    /**
     * 获取数据
     *
     * @param entity
     * @return
     */
    @Override
    public List<TimeSheetDTO> getDataInfo(TimeSheetEntity entity) {

        List<TimeSheetDTO> reList;
        try {
            reList = DataInfoUtil.castListCopy(timeSheetDao.queryDataInfo(entity), TimeSheetDTOResponse.class, TimeSheetDTO.class);
        } catch (Exception e) {
            log.info("入参对象异常,请检查：【{}】,报错信息：【{}】",entity,e);
            return null;
        }
        if (null != reList && reList.size()>0){
            return reList;
        }
        return null;
    }

    /**
     * 项目数据转换为bean
     *
     * @param list
     * @return
     */
    @Override
    public List<TimeSheetEntity> DataConver(List<TimeSheetDTO> list) {
        return DataInfoUtil.castListCopy(list,TimeSheetDTO.class,TimeSheetEntity.class);
    }
}
